<?php 
header("Content-Type: text/html; charset=utf-8");

	$con = mysql_connect("localhost","root");
	if (!$con) {
		die("连接失败。");
	}
	mysql_select_db("test", $con) or die("切换失败");

	$sql = " select * from blog";
	$res = mysql_query($sql, $con);

	if (!$res) {
		die("查询失败。");
	}

	$i = 1;
	while ($row = mysql_fetch_array($res)) {
		echo "id：";
		echo $row["id"];
		echo "<br/>";

		echo "主题：";
		echo $row["subject"];
		echo "<br/>";

		echo "内容：";
		echo $row["content"];

		echo "<br/>";
		echo "<div style="."float:right; text-align:right".">$i"."</div>";
		$i++;
		echo "<br/>";
		echo "<hr/>";
	}
	
	$i--;
	echo "<br/>";
	echo '数据库中共有'.$i.'篇文章';

?>